package org.jeecg.common.constant.enums;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 文件上传状态枚举
 *
 *
 * @author Yafei Song
 * @author: jeecg-boot
 * @date 2022/09/28
 */
public enum FileUploadStatusEnum {

    /**
     * 文件上传状态
     * 0=未上传
     */
    default_0(0, "未上传"),


    /**
     * 1=已上传
     */
    OK(1, "已上传"),


    /**
     * 2=已上传
     */
    ERROR(2, "上传失败"),


    ;


    private Integer code;

    private String desc;

    FileUploadStatusEnum(Integer code, String des) {
        this.code = code;
        this.desc = des;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }


    /**
     * 执行上传
     *  获取对应的枚举状态
     * @return {@link List}<{@link Integer}>
     */
    public static List<Integer> performUpload(){
       return Arrays.stream(FileUploadStatusEnum.values())
                .filter(m->Arrays.asList(0,2).contains(m.getCode())).map(FileUploadStatusEnum::getCode)
                .collect(Collectors.toList());
    }
}
